from selenium import webdriver

from common.BasePage import BasePage


class LoginPage(BasePage):
    def __init__(self,driver=None):
        super().__init__(driver)

        self.account_loc ="xpath,//input[@id='account']"
        self.password_loc = "xpath,//input[@id='password']"
        self.submit_loc = "xpath, //button[@id='submit']"
        self.aasert_text_loc = "xpath,/html/body/div[2]/div/div/div[1]/div"
        self.open("http://192.168.1.138/ranzhi/www/sys/index.html")

    def enter_account(self,username):
        self.input(self.account_loc,username)
        self.wait(1)

    def enter_password(self,password):
        self.input(self.password_loc,password)
        self.wait(1)

    def click_login_button(self):
        self.click(self.submit_loc)
        self.wait(2)


    def get_assert_text(self):
        return self.get_ele_text(self.aasert_text_loc)

    def test_login(self,username="admin",password="123456"):
        self.enter_account(username)
        self.enter_password(password)
        self.click_login_button()




if __name__ == '__main__':
    lg = LoginPage()
    lg.enter_account("admin")
    lg.enter_password("123456")
    lg.click_login_button()